
import BulletController from "./BulletController";
import ResMgr from "../Managers/ResMgr";

const {ccclass, property} = cc._decorator;

@ccclass
export default class Monster extends cc.Component {

    private blood_value:number = 0;


    onLoad () 
    {
        this.schedule(this.run_fire,5);

    }



    run_fire()
    {
        var num_bullet:number = 3 + Math.random() * 7;
        // var num_bullet = 2;
        for(var i:number = 0;i < Math.floor(num_bullet);i++)
        {

            var monster_bullet = BulletController.getInstace().create_Monster_bullet();
            BulletController.getInstace().node.addChild(monster_bullet);


            // var monster_bullet:cc.Node = new cc.Node();
            // monster_bullet.addComponent(cc.Sprite);
            // var textureStr:any = Math.floor(1 + Math.random() * 9);
            // console.log("textureStr-->", textureStr);
            // var texture2d = ResMgr.Instance.getAsset("Bullet",textureStr + "");

            // cc.log("texture2d===",texture2d); 
            // monster_bullet.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame();       
            // monster_bullet.getComponent(cc.Sprite).spriteFrame.setTexture(texture2d);
            // monster_bullet.setContentSize(cc.size(texture2d.width,texture2d.height));
            // BulletController.getInstace().node.addChild(monster_bullet);



            monster_bullet.x = this.node.x + (Math.random() * 640 -320); 
            monster_bullet.y = this.node.y;
        }
        


    }

    start () 
    {


    }


        
　　onCollisionEnter(other,self):void
    {
        // cc.log("onCollisionEneter>>>>>");
    }

    //=> 当两物体刚发生碰撞时被触发
　　onCollisionStay(other,self):void
    {

    }

    //=> 当两物体发生碰撞后，并且有交集的时候被触发
　　onCollisionExit(other,self):void
    {

    }





    // update (dt) {}
}
